package org.wisdom.ac.apis;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.wisdom.ac.dto.CaptchaDto;
import org.wisdom.ac.dto.LoginForm;
import org.wisdom.ac.dto.LoginInfo;
import org.wisdom.vo.ResponseResult;

/**
 * 鉴权API
 *
 * @author 张智研
 * @date 2022/05/16 07:59
 **/
@FeignClient(name = "${wisdom.ac.name:wisdom-ac}", path = "/${wisdom.ac.name:wisdom-ac}/auth",
    contextId = "wisdom-ac-auth", primary = false)
public interface AuthController {

    /**
     * 登陆
     *
     * @author 张智研
     * @date 2022/05/17 14:56
     * @param loginForm
     *            登陆用户密码
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @PostMapping(value = "/login")
    ResponseResult<LoginInfo> login(@RequestBody LoginForm loginForm);

    /**
     * 登出
     * @author 张智研
     * @date 2022/09/29 14:05
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @PostMapping(value = "/logout")
    ResponseResult<String> logout();

    /**
     * 更新token
     *
     * @author 张智研
     * @date 2022/05/30 15:03
     * @param loginForm
     *            token信息
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @PostMapping(value = "/update_token")
    ResponseResult<String> updateToken(@RequestBody LoginForm loginForm);

    /**
     * 获取验证码
     *
     * @author 张智研
     * @date 2022/09/04 14:20
     * @return org.wisdom.vo.ResponseResult<org.wisdom.ac.dto.CaptchaDto>
     */
    @GetMapping(value = "/captcha")
    ResponseResult<CaptchaDto> captcha();

    /**
     * 判断当前用户是否拥有此权限
     *
     * @author 张智研
     * @date 2023/05/16 14:56
     * @param permission 权限标识
     * @return org.wisdom.vo.ResponseResult<java.lang.String>
     */
    @GetMapping(value = "/has_permission/{permission}")
    ResponseResult<String> hasPermission(@PathVariable("permission") String permission);
}
